<!DOCTYPE html>
<html lang="zh-cn">
  <head>
    <meta charset="utf-8">
    <title>呼叫中心系统</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/css/non-responsive.css">
    <link rel="stylesheet" type="text/css" href="/css/global.css">
    <link rel="stylesheet" type="text/css" href="/css/task.css">
  </head>
  <body>
    <nav class="navbar navbar-default navbar-static-top">
      <div class="container">
        <div class="navbar-header">
          <a class="navbar-brand" href="#"><img alt="Logo" src="/img/logo.png"></a>
          <a class="navbar-brand" href="#">呼叫中心</a>
        </div>
        <div id="navbar">
          <ul class="nav navbar-nav">
            <li><a href="/status">状态监控</a></li>
            <li class="active"><a href="#">任务管理</a></li>
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">座席管理</a>
              <ul class="dropdown-menu">
                <li><a href="/user">座席管理</a></li>
                <li><a href="/exten">分机状态</a></li>
              </ul>
            </li>
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">项目管理</a>
              <ul class="dropdown-menu">
                <li><a href="/order">订单管理</a></li>
                <li class="disabled"><a href="#">客户资料管理</a></li>
                <li><a href="/product">商品管理</a></li>
                <li><a href="/sound">语音管理</a></li>
              </ul>
            </li>
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">通话记录</a>
              <ul class="dropdown-menu">
                <li><a href="/cdr/query">通话记录查询</a></li>
                <li><a href="/cdr/report">通话数据报表</a></li>
              </ul>
            </li>
            <li><a href="/help">帮助文档</a></li>
          </ul>
          <ul class="nav navbar-nav navbar-right">
            <li><a><img class="img-circle icon" src="/img/<?php echo $user->icon; ?>.png" width="19" height="19"> <?php echo mb_substr($user->name, 0, 8, 'utf-8') ?></a></li>
            <li><a id="account" href="/account">我的账户</a></li>
            <li><a href="/logout"><span class="glyphicon glyphicon-log-out" aria-hidden="true"></span> 退 出</a></li>
          </ul>
        </div>
      </div>
    </nav>

    <div class="container box">
      <div>
        <ol class="breadcrumb">
          <li class="active">当前位置:</li>
          <li><a href="#">任务管理</a></li>
          <li class="active">所有任务</li>
          <li class="pull-right"><a class="btn btn-default btn-xs" href="/task/create"><span class="glyphicon glyphicon-plus"></span> 创建任务</a></li>
        </ol>
      </div>
      <div>
        <table class="table table-condensed table-striped table-hover">
          <thead>
            <tr>
              <th class="td-icon text-center">#</th>
              <th class="text-center">任务名称</th>
              <th>任务类型</th>
              <th>已呼/总数</th>
              <th class="text-left">数据统计</th>
              <th>删除操作</th>
              <th>启动/停止</th>
              <th class="td-edit">编辑操作</th>
            </tr>
          </thead>
          <tbody class="text-muted">
          <?php
          if ($tasks != null) {
            foreach ($tasks as $id => $task) {
              if ($task['status']) {
                echo '<tr class="text-success" style="background-color:#dff0d8">',"\n";
                echo '<td><span class="glyphicon glyphicon-play-circle"></span></td>',"\n";
              } else {
                echo '<tr>',"\n";
                echo '<td><span class="glyphicon glyphicon-tasks"></span></td>',"\n";
              }
              
              echo '<td title="',$task['name'],'">',mb_substr($task['name'], 0, 5, 'utf-8'),'</td>',"\n";
              
              if ($task['type'] == 1) {
                echo '<td class="text-primary">群呼转座席</td>',"\n";
              } else if ($task['type'] == 2) {
                echo '<td class="text-primary">群呼转座席</td>',"\n";
              } else if ($task['type'] == 3) {
                echo '<td class="text-primary">点击式外呼</td>',"\n";
              } else {
                echo '<td class="text-primary">未知类型</td>',"\n";
              }

              echo '<td>',$task['total'] - $task['remainder'],'/',$task['total'],'</td>',"\n";
              echo '<td class="text-left">',"\n";
              echo '<span>接通数: <span class="label label-success">',$task['answer'],'</span></span>',"\n";

              if ($task['total'] > $task['remainder']) {
                echo '<span>接通率: <span class="label label-one">',intval(($task['answer'] / ($task['total'] - $task['remainder'])) * 100),'%</span></span>',"\n";
              } else {
                echo '<span>接通率: <span class="label label-one">0%</span></span>',"\n";
              }
              
              echo '<span>转接数: <span class="label label-two">',$task['complete'],'</span></span>',"\n";

              if ($task['answer'] > 0) {
                echo '<span>转接率: <span class="label label-three">',intval(($task['complete'] / $task['answer']) * 100),'%</span></span>',"\n";
              } else {
                echo '<span>转接率: <span class="label label-three">0%</span></span>',"\n";
              }
              
              echo '</td>',"\n";
              echo '<td><a href="javascript:;" class="btn btn-default btn-xs" onClick="deleteTask(',$id,')"><span class="glyphicon glyphicon-trash"></span> 删 除</a></td>',"\n";
              if ($task['status']) {
                echo '<td><a href="/task/stop/',$id,'" class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-unchecked"></span> 停 止</a></td>',"\n";
              } else {
                echo '<td><a href="/task/start/',$id,'" class="btn btn-success btn-xs"><span class="glyphicon glyphicon-expand"></span> 启 动</a></td>',"\n";
              }
              echo '<td class="td-edit"><a class="btn btn-default btn-xs" href="/task/edit/',$id,'"><span class="glyphicon glyphicon-edit"></span> 编 辑</a></td>',"\n";
              echo '</tr>',"\n";          
            }
          }
          ?>
          </tbody>
        </table>
      </div>
    </div>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/js/layer.js"></script>
    <script type="text/javascript" src="/js/task.js"></script>
    <script type="text/javascript">
    $('li.dropdown').mouseover(function() {   
      $(this).addClass('open');
    }).mouseout(function() {
      $(this).removeClass('open');
    });
    </script>
  </body>
</html>
